using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class StationType : EveProperty
    {
        private int dockingBayGraphicId;
        private int hangarGraphicId;
        private double xDockEntry, yDockEntry, zDockEntry;
        private double xDockOrientation, yDockOrientation, zDockOrientation;
        private int operationId;
        private int officeSlots;
        private double reprocessingEfficiency;
        private bool conquerable;

        private Operation operation;
        private Graphic dockingBayGraphic;
        private Graphic hangarGraphic;
        private Vector dockEntry;
        private Vector dockOrientation;

        public Graphic DockingBayGraphic
        {
            get
            {
                if (dockingBayGraphic == null)
                    dockingBayGraphic = new Graphic(db, dockingBayGraphicId);
                return dockingBayGraphic;
            }
        }
        public Graphic HangarGraphic
        {
            get
            {
                if (hangarGraphic == null)
                    hangarGraphic = new Graphic(db, hangarGraphicId);
                return hangarGraphic;
            }
        }
        public Vector DockEntry
        {
            get
            {
                if (dockEntry == null)
                    dockEntry = new Vector(xDockEntry, yDockEntry, zDockEntry);
                return dockEntry;
            }
        }
        public Vector DockOrientation
        {
            get
            {
                if (dockOrientation == null)
                    dockOrientation = new Vector(xDockOrientation, yDockOrientation, zDockOrientation);
                return dockOrientation;
            }
        }
        public Operation Operation
        {
            get
            {
                if (operation == null)
                    operation = new Operation(db, operationId);
                return operation;
            }
        }
        public int OfficeSlots
        {
            get { return officeSlots; }
        }
        public double ReprocessingEfficiency
        {
            get { return reprocessingEfficiency; }
        }
        public bool Conquerable
        {
            get { return conquerable; }
        }

        internal StationType(DbDataRow dr)
            : base(dr.Database, EvePropertyType.StationType, dr["stationTypeID"])
        {
            Fill(dr);
        }
        internal StationType(Database db, int id)
            : base(db, EvePropertyType.StationType, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM staStationTypes WHERE stationTypeID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            dockingBayGraphicId = dr["dockingBayGraphicID"];
            hangarGraphicId = dr["hangarGraphicID"];
            xDockEntry = dr["dockEntryX"];
            yDockEntry = dr["dockEntryY"];
            zDockEntry = dr["dockEntryZ"];
            xDockOrientation = dr["dockOrientationX"];
            yDockOrientation = dr["dockOrientationY"];
            zDockOrientation = dr["dockOrientationZ"];
            operationId = dr["operationID"];
            officeSlots = dr["officeSlots"];
            reprocessingEfficiency = dr["reprocessingEfficiency"];
            conquerable = dr["conquerable"];
        }
    }
}
